<template>
  <div class="dashboard-editor-container">
    <div class="searchSty">
      <el-button type="primary" size="large" class="btnSty" @click="fileClick('ruleForm')">归档</el-button>
      <el-form :model="form" :inline="true" class="formSty">
        <el-form-item>
          <el-button type="primary" size="large" class="btnSty" @click="searchInfo">查询</el-button>
        </el-form-item>
        <el-form-item label="井名">
          <el-input v-model="form.wellName" placeholder="井名" style="width:150px" />
        </el-form-item>
        <el-form-item label="深度(m)">
          <el-input v-model="form.depth" placeholder="深度" type="number" style="width:150px" />
        </el-form-item>
        <el-form-item label="层位">
          <el-input v-model="form.layerName" placeholder="层位" style="width:150px" />
        </el-form-item>
        <el-form-item label="资料类型">
          <el-select v-model="form.dataCategory" filterable allow-create default-first-option placeholder="请选择"
            style="width:150px" @change="bigTypechange">
            <el-option v-for="item in bigOptions" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="岩心名称">
          <el-input v-model="form.coreName" placeholder="岩心名称" style="width:150px" />
        </el-form-item>
        <el-form-item label="油气田">
          <el-input v-model="form.block" placeholder="油气田" style="width:150px" />
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column fixed prop="wellName" label="井名" align="center">
      </el-table-column>
      <el-table-column prop="syncStatus" label="资料类型" align="center">
        <template slot-scope="scope">
          <div v-if="scope.row.dataCategory == 1">
            CT扫描
          </div>
          <div v-if="scope.row.dataCategory == 2">
            电镜扫描
          </div>
          <div v-if="scope.row.dataCategory == 3">
            矿物定量扫描
          </div>
          <div v-if="scope.row.dataCategory == 4">
            冷冻电镜
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="coreName" label="岩心名称" align="center" width="150">
      </el-table-column>
      <el-table-column prop="layerName" label="层名" align="center">
      </el-table-column>
      <el-table-column prop="topDepth" label="顶深(m)" align="center">
      </el-table-column>
      <el-table-column prop="bottomDepth" label="底深(m)" align="center">
      </el-table-column>
      <el-table-column prop="block" label="油气田" align="center">
      </el-table-column>
      <el-table-column prop="address1" label="测试报告" align="center">
        <template slot-scope="scope">
          <el-tooltip class="item" effect="dark"
            :content="scope.row.testReportFileInfo ? scope.row.testReportFileInfo.fileName : '无'" placement="top">
            <div :class="scope.row.testReportFileInfo ? 'repoartSty' : ''" @click="downloadFile(scope.row)">
              {{ scope.row.testReportFileInfo ? '是' : '否' }}
            </div>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="更新时间" align="center">
      </el-table-column>
      <el-table-column prop="updaterName" label="更新人" align="center">
      </el-table-column>
      <el-table-column prop="syncStatus" label="云端同步" align="center">
        <template slot-scope="scope">
          <div style="color:#ccc" v-if="scope.row.syncStatus == 1">未同步</div>
          <div style="color:blue" v-if="scope.row.syncStatus == 2">同步中</div>
          <div v-if="scope.row.syncStatus == 3">已同步</div>
          <div style="color:red" v-if="scope.row.syncStatus == 4">同步失败</div>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" align="center" width="250">
        <template slot-scope="scope">
          <el-button type="primary" size="small" @click="handleClick(scope.row)">编辑</el-button>
          <el-button type="info" size="small" @click="viewClick(scope.row)">查看</el-button>
          <el-button type="danger" size="small" @click="deletClick(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination background layout="prev, pager, next,jumper" :total="total" style="text-align: right;margin-top:20px"
      @current-change="handleCurrentChange">
    </el-pagination>
    <el-dialog title="删除" :visible.sync="dialogVisible" width="30%">
      <span>确定删除该条数据吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose('取消')">取 消</el-button>
        <el-button type="primary" @click="handleClose('确定')">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :title="dierlogTitle" :visible.sync="addDialogVisible" width="80%" @close="dialogClose">
      <el-form :model="addform" :rules="rules" ref="ruleForm">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>基本信息</span>
          </div>
          <div class="info_box">
            <el-form-item label="井名" style="width:200px" prop="wellName">
              <el-input v-model="addform.wellName" autocomplete="off" style="width:130px" placeholder="井名"
                :disabled="wellDisabled" @blur="wellNameInpt"></el-input>
            </el-form-item>
            <el-form-item label="取样深度(m)" style="width:240px" prop="topDepth">
              <el-input v-model="addform.topDepth" autocomplete="off" style="width:130px" :disabled="topDepthDisabled"
                placeholder="取样/顶部深度" @blur="topDepthInpt"></el-input>
            </el-form-item>
            <el-form-item label="底部深度(m)" style="width:230px" prop="bottomDepth">
              <el-input v-model="addform.bottomDepth" autocomplete="off" style="width:130px" placeholder="底部深度"
                @blur="bottomDepthInpt"></el-input>
            </el-form-item>
            <el-form-item label="油气田" style="width:200px" prop="block">
              <el-input v-model="addform.block" autocomplete="off" style="width:130px" placeholder="油气田"></el-input>
            </el-form-item>
            <img src="../assets/icons/more.png" alt="" class="more_img" @click="retractClick('展开')"
              v-show="retractStatue">
          </div>
          <div class="info_box" v-show="!retractStatue">
            <el-form-item label="层位" style="width:200px" prop="layerName">
              <el-input v-model="addform.layerName" autocomplete="off" style="width:130px" placeholder="层位名称"></el-input>
            </el-form-item>
            <el-form-item label="岩心半径(m)" style="width:230px" prop="coreRadius">
              <el-input v-model="addform.coreRadius" autocomplete="off" style="width:130px"
                placeholder="定值(数值 单位)"></el-input>
            </el-form-item>
            <el-form-item label="岩心长度(m)" style="width:230px" prop="coreLength">
              <el-input v-model="addform.coreLength" autocomplete="off" style="width:130px"
                placeholder="长度(数值 单位)"></el-input>
            </el-form-item>
            <img src="../assets/icons/retract.png" alt="" class="more_img" @click="retractClick('收起')">
          </div>

        </el-card>
        <el-card class="box-card" style="margin-top:20px">
          <div slot="header" class="clearfix">
            <span>上传信息</span>
          </div>
          <div class="info_box">
            <el-form-item label="资料类型" style="width:220px" prop="dataCategory">
              <el-select v-model="addform.dataCategory" filterable allow-create default-first-option placeholder="请选择"
                style="width:150px" @change="bigTypechange" :disabled="dataCategoryDisabled">
                <el-option v-for="item in bigOptions" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="" style="width:200px" prop="dataTypeId">
              <el-select v-model="addform.dataTypeId" filterable allow-create default-first-option placeholder="请选择"
                style="width:150px;margin-left: 10px;" @change="smailTypechange" :disabled="dataTypeIdDisabled">
                <el-option v-for="item in smileOptions" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </div>
          <div class="info_box1" v-if="dialogStatus">
            <!-- <el-upload class="upload-demo" :action="uploadFileUrl" :before-upload="imgbeforUplod" :data="imgInfo"
              :on-success="handlePreview1" :on-remove="handleRemove1" :file-list="fileList1" accept=".png"> -->
            <el-upload :show-file-list="false" accept=".png,.jpg" ref="uploads" :limit="20" action
              :http-request="putinMirror" :auto-upload="true" multiple :on-exceed="onExceed1">
              <el-button size="small" type="primary" style="width:110px" :disabled="btnStatus">岩心照片</el-button>
              <el-input v-model="addform.corePhotoNmae" autocomplete="off" style="width:500px;margin-left: 20px;" disabled
                v-if="first1"></el-input>
              <el-progress :text-inside="true" :stroke-width="26" :percentage="percentage1" v-if="!first1"
                style="position:absolute;left:150px;width:400px;top:0px"></el-progress>
            </el-upload>
            <span style="margin-left: 15px;color:#ccc" v-if="first1">支持 png jpg 格式</span>
          </div>
          <!-- <div class="info_box1" v-if="dialogStatus">
            <el-upload :show-file-list="false" accept=".dcm,.tiff,.tif,.png,.jpg" ref="uploads" action :limit="limitNum"
              :on-exceed="onExceed" :http-request="putinMirror1" :auto-upload="true" multiple :on-change="upSuccess"
              :before-upload="beforeUpload" :on-error="handleError">
              <el-button size="small" type="primary" style="width:110px" :disabled="originalStatus">原始扫描图像</el-button>
              <el-input v-model="addform.mapName" autocomplete="off" style="width:500px;margin-left: 20px;" disabled
                v-if="first2"></el-input>
              <el-progress :text-inside="true" :stroke-width="26" :percentage="percentage2" v-if="!first2"
                style="position:absolute;left:150px;width:400px;top:0px"></el-progress>
            </el-upload>
            <span style="margin-left: 15px;color:#ccc" v-if="first2">支持 dcm tiff tif png jpg 格式</span>
          </div> -->
          <div class="info_box1" v-if="dialogStatus">
            <el-upload ref="upload1" class="upload-demo" action="/data/file/getS3UploadConfig"
              accept=".dcm,.tiff,.tif,.png,.jpg" :disabled="disabledUpload" :auto-upload="false" :on-change="changeFile"
              :on-error='fileErr' :on-exceed="handleExceed" :file-list="fileList9" :before-upload="beforeAvatarUpload"
              :on-success="msgSuccessOne" :data="fileData" :show-file-list="false" :multiple="true" :limit="10000">
              <el-button size="small" type="primary" style="width:110px" :disabled="originalStatus">原始扫描图像</el-button>
              <el-input v-model="addform.mapName" autocomplete="off" style="width:500px;margin-left: 20px;" disabled
                v-if="first2"></el-input>
              <el-progress :text-inside="true" :stroke-width="26" :percentage="percentage2" v-if="!first2"
                style="position:absolute;left:150px;width:400px;top:0px"></el-progress>
            </el-upload>
            <span style="margin-left: 15px;color:#ccc" v-if="first2">支持 dcm tiff tif png jpg 格式</span>
          </div>
          <!-- <div class="info_box1" v-if="dialogStatus">
            <el-upload :show-file-list="false" accept=".zip,rar,arj " ref="uploads" action :limit="limitNum"
              :on-exceed="onExceed" :http-request="putinMirror5" :auto-upload="true" multiple :on-change="upSuccess">
              <el-button size="small" type="primary" style="width:110px" :disabled="btnStatus">压缩包上传</el-button>
              <el-input v-model="addform.mapName" autocomplete="off" style="width:500px;margin-left: 20px;" disabled
                v-if="first5"></el-input>
              <el-progress :text-inside="true" :stroke-width="26" :percentage="percentage5" v-if="!first5"
                style="position:absolute;left:150px;width:400px;top:0px"></el-progress>
            </el-upload>
            <span style="margin-left: 15px;color:#ccc" v-if="first2">支持 rar、zip、arj 格式</span>
          </div> -->
          <div class="info_box1" v-if="dialogStatus">
            <el-upload :show-file-list="false" accept=".raw" ref="uploads" :limit="1" action :http-request="putinMirror2"
              :auto-upload="true">
              <el-button size="small" type="primary" style="width:110px" :disabled="btnStatus">重构数据体</el-button>
              <el-input v-model="addform.dataBodyName" autocomplete="off" style="width:500px;margin-left: 20px;" disabled
                v-if="first3"></el-input>
              <el-progress :text-inside="true" :stroke-width="26" :percentage="percentage3" v-if="!first3"
                style="position:absolute;left:150px;width:400px;top:0px"></el-progress>
            </el-upload>
            <span style="margin-left: 15px;color:#ccc" v-if="first3">支持 raw 格式</span>
          </div>
          <div class="info_box1" v-if="dialogStatus">
            <!-- <el-upload class="upload-demo" :action="uploadFileUrl" :on-success="handlePreview4" :on-remove="handleRemove4"
              :file-list="fileList3" accept=".doc,.docx" :before-upload="exebeforUplod" :data="exeInfo"> -->
            <el-upload :show-file-list="false" accept=".doc,.docx" ref="uploads" :limit="1" action
              :http-request="putinMirror3" :auto-upload="true">
              <el-button size="small" type="primary" style="width:110px" :disabled="btnStatus">数据报告</el-button>
              <el-input v-model="addform.dataTestnMame" autocomplete="off" style="width:350px;margin-left: 20px;" disabled
                v-if="first4"></el-input>
              <el-progress :text-inside="true" :stroke-width="26" :percentage="percentage4" v-if="!first4"
                style="position:absolute;left:150px;width:300px;top:0px"></el-progress>
            </el-upload>
            <el-button size="small" type="primary" style="width:50px;margin-left:40px" @click="parameterParsing"
              v-if="first4">解析</el-button>
            <el-button size="small" type="primary" style="width:50px" @click="parameterClick(formType)"
              v-if="first4">参数</el-button>
            <span style="margin-left: 15px;color:#ccc" v-if="first4">支持 doc docx 格式</span>
          </div>

        </el-card>
        <el-card class="box-card" style="margin-top:20px">
          <div slot="header" class="clearfix">
            <span>测试信息</span>
          </div>
          <div class="info_box">
            <el-form-item label="公司名字" style="width:300px" prop="companyName">
              <el-input v-model="addform.testInfo.companyName" autocomplete="off" style="width:180px;margin-left:35px"
                placeholder="测试公司名字"></el-input>
            </el-form-item>
            <el-form-item label="设备名称" style="width:300px" prop="deviceName">
              <el-input v-model="addform.testInfo.deviceName" autocomplete="off" style="width:180px;margin-left:15px"
                placeholder="测试设备名称"></el-input>
            </el-form-item>
            <el-form-item label="扫描电压(kv)" style="width:300px" prop="scanVoltage">
              <el-input v-model="addform.testInfo.scanVoltage" autocomplete="off" style="width:180px"
                placeholder="扫描电压(数值 KV)"></el-input>
            </el-form-item>

          </div>
          <div class="info_box">
            <el-form-item label="样品尺寸(mm)" style="width:300px" prop="sampleSize">
              <el-input v-model="addform.testInfo.sampleSize" autocomplete="off" style="width:180px"
                placeholder="(数值*数值*数值*单位 mm)"></el-input>
            </el-form-item>
            <el-form-item label="分辨率(μm)" style="width:300px" prop="resolution">
              <el-input v-model="addform.testInfo.resolution" autocomplete="off" style="width:180px;"
                placeholder="分辨率(数值 μm)"></el-input>
            </el-form-item>
          </div>
        </el-card>
      </el-form>
      <el-dialog width="40%" title="解析参数" :visible.sync="innerVisible" append-to-body>
        <el-form :model="parameter1" v-show="dialogType == 1" ref="parameter1Form">
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="总渗透率" style="width:400px" prop="totalPermeability">
              <el-input v-model="parameter1.totalPermeability" autocomplete="off" style="width:180px;margin-left: 45px;"
                placeholder="渗透率(数值 mD)"></el-input>
            </el-form-item>
            <el-form-item label="总孔隙度" style="width:400px" prop="totalPorosity">
              <el-input v-model="parameter1.totalPorosity" autocomplete="off" style="width:180px;;margin-left: 45px;"
                placeholder="孔隙度(数值 (小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="平均配位数" style="width:400px" prop="meanCoordinationNumber">
              <el-input v-model="parameter1.meanCoordinationNumber" autocomplete="off"
                style="width:180px;margin-left: 30px;" placeholder="配位数(数值)"></el-input>
            </el-form-item>
            <el-form-item label="最大配位数" style="width:400px" prop="maximumCoordinationNumber">
              <el-input v-model="parameter1.maximumCoordinationNumber" autocomplete="off"
                style="width:180px;;margin-left: 30px;" placeholder="配位数(数值)"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="平均孔喉比" style="width:400px" prop="averagePoreThroatRatio">
              <el-input v-model="parameter1.averagePoreThroatRatio" autocomplete="off"
                style="width:180px;margin-left: 30px;" placeholder="孔喉比(数值)"></el-input>
            </el-form-item>
            <el-form-item label="最大孔喉比" style="width:400px" prop="maximumPoreThroatRatio">
              <el-input v-model="parameter1.maximumPoreThroatRatio" autocomplete="off"
                style="width:180px;;margin-left: 30px;" placeholder="孔喉比(数值)"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="平均喉道长度" style="width:400px" prop="averageThroatLength">
              <el-input v-model="parameter1.averageThroatLength" autocomplete="off" style="width:180px;margin-left: 15px;"
                placeholder="喉道长度(数值 单位 μm)"></el-input>
            </el-form-item>
            <el-form-item label="最大喉道长度" style="width:400px" prop="maximumThroatLength">
              <el-input v-model="parameter1.maximumThroatLength" autocomplete="off"
                style="width:180px;;margin-left: 15px;" placeholder="喉道长度(数值 单位 μm)"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="平均孔隙半径" style="width:400px" prop="meanPoreRadius">
              <el-input v-model="parameter1.meanPoreRadius" autocomplete="off" style="width:180px;margin-left: 15px;"
                placeholder="孔隙半径(数值 单位 μm)"></el-input>
            </el-form-item>
            <el-form-item label="最大孔隙半径" style="width:400px" prop="maximumPoreRadius">
              <el-input v-model="parameter1.maximumPoreRadius" autocomplete="off" style="width:180px;;margin-left: 15px;"
                placeholder="孔隙半径(数值 单位 μm)"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="平均喉道半径" style="width:400px" prop="meanLaryngealRadius">
              <el-input v-model="parameter1.meanLaryngealRadius" autocomplete="off" style="width:180px;margin-left: 15px;"
                placeholder="喉道半径(数值 单位 μm)"></el-input>
            </el-form-item>
            <el-form-item label="最大喉道半径" style="width:400px" prop="maximumThroatRadius">
              <el-input v-model="parameter1.maximumThroatRadius" autocomplete="off"
                style="width:180px;;margin-left: 15px;" placeholder="喉道半径(数值 单位 μm)"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="孔隙度分布区间" style="width:400px" prop="porosityDistributionInterval">
              <el-input v-model="parameter1.porosityDistributionInterval" autocomplete="off" style="width:180px"
                placeholder="数值1,2...(最小0) %"></el-input>
            </el-form-item>
            <el-form-item label="孔隙度分布频率" style="width:400px" prop="porosityDistributionFrequency">
              <el-input v-model="parameter1.porosityDistributionFrequency" autocomplete="off" style="width:180px;"
                placeholder="数值1,2...(最小0)"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="渗透率分布区间" style="width:400px" prop="permeabilityDistributionInterval">
              <el-input v-model="parameter1.permeabilityDistributionInterval" autocomplete="off" style="width:180px"
                placeholder="数值1,2...(最小0不加) mD"></el-input>
            </el-form-item>
            <el-form-item label="渗透率分布频率" style="width:400px" prop="permeabilityDistributionFrequency">
              <el-input v-model="parameter1.permeabilityDistributionFrequency" autocomplete="off" style="width:180px;"
                placeholder="数值1,2...(最小0不加)"></el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="parameter2" v-show="dialogType == 2" ref="parameter2Form">
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="总孔隙度" style="width:400px" prop="totalPorosity">
              <el-input v-model="parameter2.totalPorosity" autocomplete="off" style="width:180px;margin-left: 45px;"
                placeholder="孔隙度(数值(小数))"></el-input>
            </el-form-item>
            <el-form-item label="有机质含量" style="width:400px" prop="organicMatterContent">
              <el-input v-model="parameter2.organicMatterContent" autocomplete="off"
                style="width:180px;;margin-left: 45px;" placeholder="含量(数值 (小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="平均配位数" style="width:400px" prop="meanCoordinationNumber">
              <el-input v-model="parameter2.meanCoordinationNumber" autocomplete="off"
                style="width:180px;margin-left: 30px;" placeholder="配位数(数值)"></el-input>
            </el-form-item>
            <el-form-item label="最大配位数" style="width:400px" prop="maximumCoordinationNumber">
              <el-input v-model="parameter2.maximumCoordinationNumber" autocomplete="off"
                style="width:180px;;margin-left: 45px;" placeholder="配位数(数值)"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="有机质孔隙度" style="width:400px" prop="organicPorosity">
              <el-input v-model="parameter2.organicPorosity" autocomplete="off" style="width:180px;margin-left: 15px;"
                placeholder="孔隙度(数值(小数))"></el-input>
            </el-form-item>
            <el-form-item label="无机质孔隙度" style="width:400px" prop="inorganicPorosity">
              <el-input v-model="parameter2.inorganicPorosity" autocomplete="off" style="width:180px;;margin-left: 30px;"
                placeholder="孔隙度(数值(小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="有机缝孔隙度" style="width:400px" prop="organicFracturePorosity">
              <el-input v-model="parameter2.organicFracturePorosity" autocomplete="off"
                style="width:180px;margin-left: 15px;" placeholder="孔隙度(数值(小数))"></el-input>
            </el-form-item>
            <el-form-item label="无机缝孔隙度" style="width:400px" prop="inorganicFracturePorosity">
              <el-input v-model="parameter2.inorganicFracturePorosity" autocomplete="off"
                style="width:180px;;margin-left: 30px;" placeholder="孔隙度(数值(小数))"></el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="parameter3" v-show="dialogType == 3" ref="parameter3Form">
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="石英" style="width:400px" prop="quartz">
              <el-input v-model="parameter3.quartz" autocomplete="off" style="width:180px;margin-left: 65px;"
                placeholder="含量(数值(小数))"></el-input>
            </el-form-item>
            <el-form-item label="长石" style="width:400px" prop="feldspar">
              <el-input v-model="parameter3.feldspar" autocomplete="off" style="width:180px;;margin-left: 55px;"
                placeholder="含量(数值 (小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="方解石" style="width:400px" prop="calcite">
              <el-input v-model="parameter3.calcite" autocomplete="off" style="width:180px;margin-left: 50px;"
                placeholder="含量(数值 (小数))"></el-input>
            </el-form-item>
            <el-form-item label="白云石" style="width:400px" prop="dolomite">
              <el-input v-model="parameter3.dolomite" autocomplete="off" style="width:180px;;margin-left: 40px;"
                placeholder="含量(数值 (小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="粘土类矿物" style="width:400px" prop="clayTypeMineral">
              <el-input v-model="parameter3.clayTypeMineral" autocomplete="off" style="width:180px;margin-left: 25px;"
                placeholder="含量(数值 (小数))"></el-input>
            </el-form-item>
            <el-form-item label="其他矿物" style="width:400px" prop="otherMinerals">
              <el-input v-model="parameter3.otherMinerals" autocomplete="off" style="width:180px;;margin-left: 30px;"
                placeholder="含量(数值 (小数))"></el-input>
            </el-form-item>
          </div>
        </el-form>
        <el-form :model="parameter4" v-show="dialogType == 4" ref="parameter4Form">
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="总孔隙度" style="width:400px" prop="totalPorosity">
              <el-input v-model="parameter4.totalPorosity" autocomplete="off" style="width:180px;margin-left: 60px;"
                placeholder="孔隙度(数值(小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="总含油饱和度" style="width:400px" prop="totalOilSaturation">
              <el-input v-model="parameter4.totalOilSaturation" autocomplete="off" style="width:180px;margin-left: 30px;"
                placeholder="含量(数值(小数))"></el-input>
            </el-form-item>
            <el-form-item label="总含水包饱和度" style="width:400px" prop="totalWaterSaturation">
              <el-input v-model="parameter4.totalWaterSaturation" autocomplete="off"
                style="width:180px;;margin-left: 30px;" placeholder="含量(数值(小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="小孔孔隙度" style="width:400px" prop="porePorosity">
              <el-input v-model="parameter2.porePorosity" autocomplete="off" style="width:180px;margin-left: 45px;"
                placeholder="孔隙度(数值(小数))"></el-input>
            </el-form-item>
            <el-form-item label="大孔孔隙度" style="width:400px" prop="largePorePorosity">
              <el-input v-model="parameter2.largePorePorosity" autocomplete="off" style="width:180px;;margin-left: 60px;"
                placeholder="孔隙度(数值(小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="小孔含油量" style="width:400px" prop="smallHoleOilContent">
              <el-input v-model="parameter4.smallHoleOilContent" autocomplete="off" style="width:180px;margin-left: 45px;"
                placeholder="含量(数值(小数))"></el-input>
            </el-form-item>
            <el-form-item label="大孔含油量" style="width:400px" prop="largeHoleOilContent">
              <el-input v-model="parameter4.largeHoleOilContent" autocomplete="off"
                style="width:180px;;margin-left: 60px;" placeholder="含量(数值(小数))"></el-input>
            </el-form-item>
          </div>
          <div style='width: 100%;display: flex;;align-items: center;'>
            <el-form-item label="小孔油状态" style="width:400px" prop="pinholeOilCondition">
              <el-input v-model="parameter4.pinholeOilCondition" autocomplete="off" style="width:180px;margin-left: 45px;"
                placeholder="充填/薄膜/管束状"></el-input>
            </el-form-item>
            <el-form-item label="大孔油状态" style="width:400px" prop="largeHoleOilState">
              <el-input v-model="parameter4.largeHoleOilState" autocomplete="off" style="width:180px;;margin-left: 60px;"
                placeholder="充填/薄膜/管束状"></el-input>
            </el-form-item>
          </div>
        </el-form>
      </el-dialog>

      <div slot="footer" class="dialog-footer">
        <el-button @click="addDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
      </div>
    </el-dialog>
    <ViewPage :state="viewStatus" :info="viewInfo" @stateChange="viewchange" :allValue="addform" v-if="viewStatus">
    </ViewPage>

  </div>
</template>

<script>
import axios from 'axios';
import ViewPage from './viewPage.vue'
import { archivedInformation, informationDetails, listPost, firstFileUp, secendFileUp, addInfo, parameterParsings, delArchivedInformation, editInfo, sliceFileDownload, getFileToken, postFileToken, saveFileToken } from "@/api/system/post";
import md5 from 'blueimp-md5'
import { getAccessToken, getRefreshToken } from '@/utils/auth'
export default {
  name: 'Index',
  components: {
    ViewPage,
  },
  data() {
    return {
      dataList: [],
      uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/data/file/uploadPart", // 请求地址
      tableData: [],
      form: {
        wellName: "",
        dataTypeId: '',
        coreName: '',
        block: '',
        layerName: '',
        pageNo: 1,
        pageSize: 10,
      },
      addform: {
        id: '',
        wellName: '',
        topDepth: '',
        bottomDepth: '',
        block: '',
        corePhotoNmae: '',
        dataBodyName: '',
        mapName: '',
        layedataTyperName: '',
        dataTestnMame: '',
        coreRadius: '',
        coreLength: '',
        dataCategory: '',
        dataTypeId: '',
        coreImageFileList: [],
        originalScanImageFileList: [],
        refactorDataBodyFile: null,
        testReportFile: null,
        testInfo: {
          companyName: "",
          deviceName: "",
          scanVoltage: "",
          sampleSize: '',
          resolution: "",
          testReportFile: {
            fileId: '',
            fileName: '',
            location: "",

          },
          testParams: {}
        }
      },
      parameter1: {
        totalPermeability: "",
        totalPorosity: '',
        meanCoordinationNumber: '',
        maximumCoordinationNumber: "",
        averagePoreThroatRatio: "",
        maximumPoreThroatRatio: "",
        averageThroatLength: "",
        maximumThroatLength: "",
        meanPoreRadius: '',
        maximumPoreRadius: '',
        meanLaryngealRadius: '',
        maximumThroatRadius: '',
        porosityDistributionInterval: '',
        porosityDistributionFrequency: '',
        permeabilityDistributionInterval: '',
        permeabilityDistributionFrequency: "",
      },
      parameter2: {
        totalPorosity: "",
        organicMatterContent: '',
        meanCoordinationNumber: '',
        maximumCoordinationNumber: "",
        organicPorosity: '',
        inorganicPorosity: "",
        organicFracturePorosity: "",
        inorganicFracturePorosity: "",
      },
      parameter3: {
        quartz: "",
        feldspar: '',
        calcite: '',
        dolomite: "",
        clayTypeMineral: "",
        otherMinerals: "",
      },
      parameter4: {
        totalPorosity: "",
        totalOilSaturation: '',
        totalWaterSaturation: '',
        porePorosity: "",
        largePorePorosity: "",
        smallHoleOilContent: "",
        largeHoleOilContent: "",
        pinholeOilCondition: "",
        largeHoleOilState: '',
      },
      pageNum: 1,
      pageSize: 10,
      dialogVisible: false,
      addDialogVisible: false,
      retractStatue: true,
      innerVisible: false,
      dialogType: 1, // 参数类型
      bigOptions: [
        {
          value: '',
          label: '全部'
        },
        {
          value: 1,
          label: 'CT扫描'
        },
        {
          value: 2,
          label: '电镜扫描'
        },
        {
          value: 3,
          label: '矿物定量扫描'
        },
        {
          value: 4,
          label: '冷冻电镜'
        },
      ],
      smileOptions: [],
      fileList1: [],
      fileList2: [],
      fileList3: [],
      fileList4: [],
      fileList5: [],
      fileNmae: [],
      rules: {
        wellName: [
          { required: true, message: '请输入井名', trigger: 'blur' },
          // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        samplingDepth: [
          { required: true, message: '请输入取样深度', trigger: 'blur' }
        ],
        topDepth: [
          { required: true, message: '请输入顶深', trigger: 'blur' },
        ]
      },
      formType: 'parameter1Form',
      viewStatus: false,
      viewInfo: {},
      imgInfo: {},
      exeInfo: {},
      AList: [],
      dierlogTitle: '岩心归档(新增)',
      deletInfo: {},
      total: 1,
      first1: true,
      first2: true,
      first3: true,
      first4: true,
      first5: true,
      percentage1: 0,
      percentage2: 0,
      percentage3: 0,
      percentage4: 0,
      percentage5: 0,
      dialogStatus: false,
      wellDisabled: false,
      topDepthDisabled: false,
      dataCategoryDisabled: false,
      dataTypeIdDisabled: false,
      loadFile: '',
      list: [],
      btnStatus: true,
      moreFileList: [],
      limitNum: 10000, // 最大上传数量
      originalStatus: true,
      uploading: false,

      fileNum: '',  // 单词递归上传的文件
      upFileList: '',//需要依次上传的待传列表
      percentTotal: 0,//总上传个数
      percentNow: 0,//当前上传个数
      showDesc: '',//结束文案
      showPercent: false,//显示上传进度条
      time: null,// change事件是否结束 是否可以直接调手动上传事件（目前设置1.5s）
      disabledUpload: false,//正在上传中 禁止再次选择文件上传

      fileData: {
      },//上传参数

      fileList9: [],
      name: '',
      samllFileName: '',
      filePath: '',
      partSize: '',
      etag: '',
      fileSize: '',
      totalSlice: 0,
    }
  },
  mounted() {
    this.getInformation()
  },
  watch: {
    smileOptions: {
      immediate: true,
      handler(val) {
        this.smileOptions = val
      }
    },
    addform: {
      immediate: true,
      handler(val) {
        this.addform = val
        this.addform.corePhotoNmae = val.corePhotoNmae
        this.addform.dataBodyName = val.dataBodyName
        this.addform.mapName = val.mapName
        this.addform.dataTestnMame = val.dataTestnMame
      },
      deep: true
    },
    viewInfo: {
      immediate: true,
      handler(val) {
        this.viewInfo = val
      },
      deep: true
    },
    fileList1: {
      immediate: true,
      handler(val) {
        this.fileList1 = val
      },
      deep: true
    },
    fileList2: {
      immediate: true,
      handler(val) {
        this.fileList2 = val
      },
      deep: true
    },
    fileList3: {
      immediate: true,
      handler(val) {
        this.fileList3 = val
      },
      deep: true
    }, fileList4: {
      immediate: true,
      handler(val) {
        this.fileList4 = val
      },
      deep: true
    },
    fileList5: {
      immediate: true,
      handler(val) {
        this.fileList5 = val
      },
      deep: true
    },

  },

  methods: {
    // 上传之前
    beforeUpload(file) {
      console.log(file, 11111)
      if (this.uploading) {
        return false; // 如果有文件正在上传，就不处理当前文件，等待上一个文件上传完成
      }
      // ... 文件校验逻辑
      this.uploading = true; // 标记有文件正在上传
      return true;
    },
    // 上传失败
    handleError(error, file, fileList) {
      console.log(error, file, fileList);
      this.uploading = false; // 标记上传完成
    },

    // 岩心照片超出上限制
    onExceed1() {
      this.$message({
        message: '最多上传20张图片！',
        type: 'warning'
      });
    },
    // 上传超出限制
    onExceed() {
      this.$message({
        message: '最多上传10000个文件！',
        type: 'warning'
      });
    },
    // 多文件上传成功
    upSuccess(file, fileList) {
      let name = ''
      fileList.map((res) => {
        name = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_原始扫描图像_${res.name}` + ',' + name
      })
      this.$set(this.addform, 'mapName', name)
      this.uploading = false; // 标记上传完成
    },
    // 输入井名促发
    wellNameInpt(event) {
      if (this.addform.wellName && this.addform.topDepth) {
        this.dataCategoryDisabled = false
        this.dataTypeIdDisabled = false
      } else {
        this.dataCategoryDisabled = true
        this.dataTypeIdDisabled = true
      }
    },
    // 输入顶深触发
    topDepthInpt(event) {
      if (this.addform.wellName && this.addform.topDepth) {
        this.dataCategoryDisabled = false
        this.dataTypeIdDisabled = false
      } else {
        this.dataCategoryDisabled = true
        this.dataTypeIdDisabled = true
      }

    },
    // 触发底深
    bottomDepthInpt() {
      if (this.addform.wellName && this.addform.topDepth && this.addform.bottomDepth && this.addform.dataTypeId) {
        this.originalStatus = false
      } else {
        this.originalStatus = true
      }
    },
    // 新增编辑弹框关闭
    dialogClose() {
      this.clearForm()
      this.fileList1 = []
      this.fileList2 = []
      this.fileList3 = []
      this.fileList4 = []
      this.fileList5 = []
      this.dialogStatus = false
    },
    //上传文件参数解析     
    parameterParsing() {
      if (this.addform.wellName) {
        if (this.addform.topDepth) {
          if (this.addform.dataTypeId) {
            let obj = {
              wellName: this.addform.wellName,
              topDepth: this.addform.topDepth,
              dataTypeId: this.addform.dataTypeId,
              fileId: '',
            }
            if (this.fileList4) {
              this.fileList4.map((res) => {
                if (res) {
                  obj.fileId = res.fileId
                }

              })


            }
            parameterParsings(obj).then((res) => {
              if (res.data.dataCategory === 1) {
                this.parameter1 = res.data.testParams
              } else if (res.data.dataCategory === 2) {
                this.parameter2 = res.data.testParams
              } else if (res.data.dataCategory === 3) {
                this.parameter3 = res.data.testParams
              } else if (res.data.dataCategory === 4) {
                this.parameter4 = res.data.testParams
              }
              this.addform.testInfo.companyName = res.data.companyName
              this.addform.testInfo.deviceName = res.data.deviceName
              this.addform.testInfo.resolution = res.data.resolution
              this.addform.testInfo.sampleSize = res.data.sampleSize
              this.addform.testInfo.scanVoltage = res.data.scanVoltage
              this.$message({
                message: '解析成功',
                type: 'success'
              });
            })
          } else {
            this.$message({
              message: '请选择资料类型',
              type: 'warning'
            });
            return false;
          }
        } else {
          this.$message({
            message: '请填写顶深',
            type: 'warning'
          });
          return false;
        }
      } else {
        this.$message({
          message: '请填写井名',
          type: 'warning'
        });
        return false;
      }

    },
    // md5加密
    md5Hash(file) {
      const reader = new FileReader();
      reader.readAsArrayBuffer(file);
      reader.onload = () => {
        const arrayBuffer = reader.result;
        const hash = md5(arrayBuffer);
        return hash;
      };
      return reader;
    },
    // 数据报告上传之前
    exebeforUplod(file) {
      this.exeInfo = file.name
    },
    // 图片上传之前
    imgbeforUplod(file) {
      this.imgInfo.fileName = file.name
    },
    // 查询归档信息列表
    getInformation() {

      archivedInformation(this.form).then(response => {
        this.tableData = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 点击查看
    viewClick(value) {
      this.clearForm()
      this.viewInfo = {}
      this.AList = []
      informationDetails(value.archiveId).then(response => {
        let data = JSON.parse(JSON.stringify(response.data))
        if (value.dataCategory == 1) {
          let name = data.testInfo.testParams.porosityDistributionInterval
          let value = data.testInfo.testParams.porosityDistributionFrequency
          let a = name ? name.split(',') : []
          let b = value ? value.split(',') : []
          let info = [...['0'], ...a]
          this.getInfo(info)
          this.viewInfo.value = b
          this.viewInfo.name = this.AList
          let name1 = data.testInfo.testParams.permeabilityDistributionInterval
          let value1 = data.testInfo.testParams.permeabilityDistributionFrequency
          let a1 = name1 ? name1.split(',') : []
          let b1 = value1 ? value1.split(',') : []
          let info1 = [...['0'], ...a1]
          this.getInfo(info1)
          this.viewInfo.value1 = b1
          this.viewInfo.name1 = this.AList

        } else if (value.dataCategory == 2) {
          let b = []
          let a = []
          let obj = response.data.testInfo.testParams
          for (var key in obj) {
            if (key == 'quartz') {
              a.push('石英')
            } else if (key == 'feldspar') {
              a.push('长石')
            } else if (key == 'calcite') {
              a.push('方解石')
            } else if (key == 'dolomite') {
              a.push('白云石')
            } else if (key == 'clayTypeMineral') {
              a.push('粘土类矿物')
            } else if (key == 'otherMinerals') {
              a.push('其他矿物')
            }
            b.push(obj[key])
          }
          this.viewInfo.value = b
          this.viewInfo.name = a
          // this.parameter3 = response.data.data.testInfo.testParams
        }
        if (data.coreImageFileList) {
          data.coreImageFileList.map((res) => {
            this.getFile(res.fileId, 1)
          })
        }
        if (data.originalScanImageFileList) {
          data.originalScanImageFileList.map((res) => {
            this.getFile(res.fileId, 2)
          })
        }
        if (data.refactorDataBodyFile) {
          this.getFile(data.refactorDataBodyFile.fileId, 3)
        }
        if (data.testReportFile) {
          this.getFile(data.testReportFile.fileId, 4)
        }
        this.addform = data;
        this.loading = false;
        setTimeout(() => {
          this.viewStatus = true

        }, 100)
      });

    },
    // 循环下载文件
    getFile(id, type) {
      sliceFileDownload(id).then((res) => {
        let list = []
        if (res.data.partList) {
          res.data.partList.map((item) => {
            let instance = axios.create({
              responseType: 'blob',
            })
            instance.get(`${item.fileDownloadUrl}`).then((info) => {
              list.push(info.data)
              if (res.data.partCount == list.length) {
                let blob = new Blob(list);
                let link = document.createElement('a');
                link.href = window.URL.createObjectURL(blob);
                let para = {
                  fileId: id,
                  fileName: res.data.fileName,
                  location: link.href
                }
                if (type == 1) {
                  this.addform.coreImageFileList.push(para)
                  this.addform.coreImageFileList.map((res, index) => {
                    if (!res.location) {
                      this.addform.coreImageFileList.splice(index, 1)
                    }
                  })
                } else if (type == 2) {
                  this.addform.originalScanImageFileList.push(para)
                  this.addform.originalScanImageFileList.map((res, index) => {
                    if (!res.location) {
                      this.addform.originalScanImageFileList.splice(index, 1)
                    }
                  })
                } else if (type == 3) {
                  this.addform.refactorDataBodyFile = para
                } else if (type == 4) {
                  this.addform.testReportFile = para
                } else if (type == 'other') {
                  let name = res.data.fileName.slice(res.data.fileName.lastIndexOf('.') + 1)
                  link.download = res.data.fileName
                  document.body.appendChild(link)
                  link.click()
                  setTimeout(() => {
                    window.URL.revokeObjectURL(href)
                    document.body.removeChild(link)
                  }, 0)
                }

              }
            })

          })
        }
      })
    },
    // 递归取数据
    getInfo(info) {

      if (info.length > 0) {
        info.map((res, index) => {
          let obj = `${info[index]}-${info[index + 1]}`
          this.AList.push(obj)
          info.splice(0, 1)
          if (info.length > 1) {
            this.getInfo(info)
          } else {
            return
          }
        })
      }

    },
    // 查看关闭
    viewchange() {
      this.viewStatus = false
    },
    // 新增确定
    submitForm(formName) {
      this.addform.coreImageFileList = []
      this.addform.originalScanImageFileList = []
      this.addform.refactorDataBodyFile = null
      this.addform.testReportFile = null
      if (this.fileList1.length > 0) {
        this.fileList1.map((res) => {
          let obj = {
            fileId: "",
            fileName: "",
            location: "",
          }
          obj.fileId = res.fileId
          obj.fileName = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_岩心照片_${this.addform.corePhotoNmae}`
          obj.location = res.location
          this.addform.coreImageFileList.push(obj)
        })
      }
      if (this.fileList2.length > 0) {
        this.fileList2.map((res) => {
          let obj = {
            fileId: "",
            fileName: "",
            location: "",
          }
          obj.fileId = res.fileId
          obj.fileName = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_原始扫描图像_${res.fileName}`
          obj.location = res.location
          this.addform.originalScanImageFileList.push(obj)
        })
      }
      if (this.fileList3.length > 0) {
        this.fileList3.map((res) => {
          if (res) {
            let obj = {
              fileId: "",
              fileName: "",
              location: "",
            }
            obj.fileId = res.fileId
            obj.fileName = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_重构数据体_${this.addform.dataBodyName}`
            obj.location = res.location
            this.addform.refactorDataBodyFile = obj
          }

        })
      }
      if (this.fileList4.length > 0) {
        this.fileList4.map((res) => {
          if (res) {
            let obj = {
              fileId: "",
              fileName: "",
              location: "",
            }
            obj.fileId = res.fileId
            obj.fileName = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_数据报告_${this.addform.dataTestnMame}`
            obj.location = res.location
            this.addform.testReportFile = obj
          }

        })
      }
      // if (this.fileList5.length > 0) {
      //   this.fileList5.map((res) => {
      //     let obj = {
      //       fileId: "",
      //       fileName: "",
      //       location: "",
      //     }
      //     obj.fileId = res.fileId
      //     obj.fileName = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_原始扫描图像_${this.addform.mapName}`
      //     obj.location = res.location
      //     this.addform.originalScanImageFileList.push(obj)
      //   })
      // }
      this.addform.testInfo.dataCategory = this.addform.dataCategory
      this.addform.testInfo.dataTypeId = this.addform.dataTypeId
      if (this.addform.dataCategory === 1) {
        this.addform.testInfo.testParams = this.parameter1
      } else if (this.addform.dataCategory === 2) {
        this.addform.testInfo.testParams = this.parameter2
      } else if (this.addform.dataCategory === 3) {
        this.addform.testInfo.testParams = this.parameter3
      } else if (this.addform.dataCategory === 4) {
        this.addform.testInfo.testParams = this.parameter4
      }
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.dierlogTitle == '岩心归档(新增)') {
            addInfo(this.addform).then((res) => {
              if (res.code == 0) {
                this.addDialogVisible = false
                this.getInformation()
              }
            })
          } else {
            editInfo(this.addform, this.addform.id).then((res) => {
              if (res.code == 0) {
                this.addDialogVisible = false
                this.getInformation()
              }
            })
          }


          this.$refs[formName].resetFields()
          this.clearForm()

        } else {
          this.$message({
            message: '请填写必要内容',
            type: 'warning'
          });
          return false;
        }
      });
    },
    // 岩心照片上传
    putinMirror(file) {
      getFileToken().then((res1) => {
        var name = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_岩心照片_${file.file.name}`
        // 每个文件切片大小定为5MB
        var sliceSize = 90 * 1024 * 1024;
        //文件大小限制为最大10个G，可根据需求修改
        var filesizes = 100 * 1024 * 1024 * 1024;
        let that = this;
        const blob = file.file;
        var fileSize = blob.size;// 文件大小
        // this.fileNmae.push(blob.name)
        const fileName = blob.name;// 文件名
        //计算文件切片总数
        var totalSlice = 0;
        if (fileSize >= sliceSize) {
          totalSlice = Math.ceil(fileSize / sliceSize)
        } else {
          totalSlice = 1
        }
        var list = []

        if (fileSize <= filesizes) {
          // 循环上传
          for (let i = 0; i < totalSlice; i++) {
            let start = i * sliceSize;
            let chunk = blob.slice(start, Math.min(fileSize, start + sliceSize));
            let files = new File([chunk], name)
            let partSize = files.size
            var num = null
            num = i + 1
            let samllFileName = name + "_part_" + num + ".dat"
            let filePath = res1.data.key + samllFileName + res1.data.time_yyyyMMddHHmmssS + '.dat'
            var formData = new FormData();
            formData.append("name", '');
            formData.append("acl", 'public-read');
            formData.append("AWSAccessKeyId", res1.data.accessKey);
            formData.append("policy", res1.data.policy);
            formData.append("signature", res1.data.signature);
            formData.append("policy", res1.data.policy);
            formData.append("key", filePath);
            formData.append("Content-Type", '');
            formData.append("file", files);
            this.first1 = false
            let instance = axios.create({
              baseURL: 'baseUrl',
              data: formData,
            })
            instance.post(`${res1.data.bucketEndpoint}`, formData)
              .then((res2) => {
                let etag = res2.headers.etag
                let etags = etag.replace(/"/g, '')
                let param = {
                  storageName: res1.data.storageName,
                  filePath: filePath,
                  etag: etags,
                  fileName: samllFileName,
                  fileSize: partSize,
                  dataRegion: res1.data.dataRegion
                }
                postFileToken(param).then((res3) => {
                  let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                  let endIndex = res3.data.fileName.lastIndexOf(".dat")
                  let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                  let obj = {
                    fssFileId: res3.data.fileId,
                    partFileName: res3.data.fileName,
                    partNumber: Number(partNumber),
                    partSize: res3.data.fileSize
                  }
                  list.push(obj)
                  this.percentage1 = Number(((list.length / totalSlice) * 100).toFixed(2))
                  if (list.length == totalSlice) {
                    let params = {
                      fileName: name,
                      fileSize: fileSize,
                      partFileList: list
                    }
                    saveFileToken(params).then((res4) => {
                      this.fileList1.push(res4.data)
                      this.$set(this.addform, 'corePhotoNmae', name)
                      this.percentage1 = 100
                      this.first1 = true
                    })
                  }

                })
              }).catch((res2) => {
                that.$message({
                  message: '因网络延时，上传失败！请重新上传',
                  type: 'error'
                });
              })
          }


        } else {
          that.$message({
            message: '文件大小超出90G',
            type: 'error'
          });
        }

      })
      // let name = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_岩心照片_${file.file.name}`
      // let param = {
      //   fileName: name
      // }
      // firstFileUp(param).then(async (response) => {

      //   var uploadId = response.data.uploadId
      //   // 每个文件切片大小定为5MB
      //   var sliceSize = 90 * 1024 * 1024;
      //   //文件大小限制为最大10个G，可根据需求修改
      //   var filesizes = 100 * 1024 * 1024 * 1024;
      //   let that = this;
      //   const blob = file.file;
      //   const fileSize = blob.size;// 文件大小
      //   // this.fileNmae.push(blob.name)
      //   const fileName = blob.name;// 文件名
      //   //计算文件切片总数
      //   var totalSlice = 0;
      //   if (fileSize >= sliceSize) {
      //     totalSlice = Math.ceil(fileSize / sliceSize)
      //   } else {
      //     totalSlice = 1
      //   }
      //   var list = []
      //   if (fileSize <= filesizes) {
      //     // 循环上传
      //     for (let i = 0; i < totalSlice; i++) {
      //       let start = i * sliceSize;
      //       let chunk = blob.slice(start, Math.min(fileSize, start + sliceSize));
      //       let files = new File([chunk], fileName)
      //       let partSize = files.size
      //       this.fileMd5Sum.fileMd5Sum(files).then(res => {
      //         var formData = new FormData();
      //         formData.append("uploadId", uploadId);
      //         formData.append("file", files);
      //         formData.append("partSize", partSize);
      //         formData.append("partNumber", i + 1);
      //         formData.append("md5Digest", res);
      //         this.first1 = false
      //         let instance = axios.create({
      //           baseURL: 'baseUrl',
      //           data: formData,
      //           headers: { 'Content-Type': 'multipart/form-data', 'Authorization': "Bearer " + getAccessToken() }

      //         })
      //         instance.post(`${this.uploadFileUrl}`, formData)
      //           .then((res) => {
      //             if (res.data.code == 0) {
      //               list.push(res.data.data)
      //               this.percentage1 = Number(((list.length / totalSlice) * 100).toFixed(2))
      //               if (list.length == totalSlice) {
      //                 let param = {
      //                   uploadId: uploadId,
      //                   partTags: list
      //                 }
      //                 secendFileUp(param).then(response => {
      //                   this.fileList1.push(response.data)
      //                   this.$set(this.addform, 'corePhotoNmae', response.data.fileName)
      //                   this.percentage1 = 100
      //                   this.first1 = true
      //                 });
      //               }

      //             } else {
      //               that.$message({
      //                 message: res.msg,
      //                 type: 'error'
      //               });
      //             }


      //           }).catch((res) => {
      //             that.$message({
      //               message: '因网络延时，上传失败！请重新上传',
      //               type: 'error'
      //             });
      //           })
      //       });
      //     }


      //   } else {
      //     that.$message({
      //       message: '文件大小超出90G',
      //       type: 'error'
      //     });
      //   }
      // });
    },
    // 原始扫描图件上传
    putinMirror1(file) {
      getFileToken().then((res1) => {
        var name = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_原始扫描图像_${file.file.name}`
        // 每个文件切片大小定为5MB
        var sliceSize = 90 * 1024 * 1024;
        //文件大小限制为最大10个G，可根据需求修改
        var filesizes = 100 * 1024 * 1024 * 1024;
        let that = this;
        const blob = file.file;
        var fileSize = blob.size;// 文件大小
        //计算文件切片总数
        var totalSlice = 0;
        if (fileSize >= sliceSize) {
          totalSlice = Math.ceil(fileSize / sliceSize)
        } else {
          totalSlice = 1
        }
        var list = []

        if (fileSize <= filesizes) {
          // 循环上传
          for (let i = 0; i < totalSlice; i++) {
            let start = i * sliceSize;
            let chunk = blob.slice(start, Math.min(fileSize, start + sliceSize));
            let files = new File([chunk], name)
            let partSize = files.size
            var num = null
            num = i + 1
            let samllFileName = name + "_part_" + num + ".dat"
            let filePath = res1.data.key + samllFileName + res1.data.time_yyyyMMddHHmmssS + '.dat'
            var formData = new FormData();
            formData.append("name", '');
            formData.append("acl", 'public-read');
            formData.append("AWSAccessKeyId", res1.data.accessKey);
            formData.append("policy", res1.data.policy);
            formData.append("signature", res1.data.signature);
            formData.append("policy", res1.data.policy);
            formData.append("key", filePath);
            formData.append("Content-Type", '');
            formData.append("file", files);
            this.first2 = false
            let instance = axios.create({
              baseURL: 'baseUrl',
              data: formData,
              timeout: 1000000,
            })
            instance.post(`${res1.data.bucketEndpoint}`, formData)
              .then((res2) => {
                let etag = res2.headers.etag
                let etags = etag.replace(/"/g, '')
                let param = {
                  storageName: res1.data.storageName,
                  filePath: filePath,
                  etag: etags,
                  fileName: samllFileName,
                  fileSize: partSize,
                  dataRegion: res1.data.dataRegion
                }
                postFileToken(param).then((res3) => {
                  let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                  let endIndex = res3.data.fileName.lastIndexOf(".dat")
                  let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                  let obj = {
                    fssFileId: res3.data.fileId,
                    partFileName: res3.data.fileName,
                    partNumber: Number(partNumber),
                    partSize: res3.data.fileSize
                  }
                  list.push(obj)
                  this.percentage2 = Number(((list.length / totalSlice) * 100).toFixed(2))
                  if (list.length == totalSlice) {
                    let params = {
                      fileName: name,
                      fileSize: fileSize,
                      partFileList: list
                    }
                    saveFileToken(params).then((res4) => {
                      this.fileList2.push(res4.data)
                      this.percentage2 = 100
                      this.first2 = true
                    })

                  }

                })
              }).catch((res2) => {
                that.$message({
                  message: '因网络延时，上传失败！请重新上传',
                  type: 'error'
                });
              })
          }


        } else {
          that.$message({
            message: '文件大小超出90G',
            type: 'error'
          });
        }
      })
    },
    // 重构数据体上传
    putinMirror2(file) {
      getFileToken().then((res1) => {
        var name = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_重构数据体_${file.file.name}`
        // 每个文件切片大小定为5MB
        var sliceSize = 90 * 1024 * 1024;
        //文件大小限制为最大10个G，可根据需求修改
        var filesizes = 100 * 1024 * 1024 * 1024;
        let that = this;
        const blob = file.file;
        var fileSize = blob.size;// 文件大小
        // this.fileNmae.push(blob.name)
        const fileName = blob.name;// 文件名
        //计算文件切片总数
        var totalSlice = 0;
        if (fileSize >= sliceSize) {
          totalSlice = Math.ceil(fileSize / sliceSize)
        } else {
          totalSlice = 1
        }
        var list = []

        if (fileSize <= filesizes) {
          // 循环上传
          for (let i = 0; i < totalSlice; i++) {
            let start = i * sliceSize;
            let chunk = blob.slice(start, Math.min(fileSize, start + sliceSize));
            let files = new File([chunk], name)
            let partSize = files.size
            var num = null
            num = i + 1
            let samllFileName = name + "_part_" + num + ".dat"
            let filePath = res1.data.key + samllFileName + res1.data.time_yyyyMMddHHmmssS + '.dat'
            var formData = new FormData();
            formData.append("name", '');
            formData.append("acl", 'public-read');
            formData.append("AWSAccessKeyId", res1.data.accessKey);
            formData.append("policy", res1.data.policy);
            formData.append("signature", res1.data.signature);
            formData.append("policy", res1.data.policy);
            formData.append("key", filePath);
            formData.append("Content-Type", '');
            formData.append("file", files);
            this.first3 = false
            let instance = axios.create({
              baseURL: 'baseUrl',
              data: formData,
            })
            instance.post(`${res1.data.bucketEndpoint}`, formData)
              .then((res2) => {
                let etag = res2.headers.etag
                let etags = etag.replace(/"/g, '')
                let param = {
                  storageName: res1.data.storageName,
                  filePath: filePath,
                  etag: etags,
                  fileName: samllFileName,
                  fileSize: partSize,
                  dataRegion: res1.data.dataRegion
                }
                postFileToken(param).then((res3) => {
                  let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                  let endIndex = res3.data.fileName.lastIndexOf(".dat")
                  let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                  let obj = {
                    fssFileId: res3.data.fileId,
                    partFileName: res3.data.fileName,
                    partNumber: Number(partNumber),
                    partSize: res3.data.fileSize
                  }
                  list.push(obj)
                  this.percentage3 = Number(((list.length / totalSlice) * 100).toFixed(2))
                  if (list.length == totalSlice) {
                    let params = {
                      fileName: name,
                      fileSize: fileSize,
                      partFileList: list
                    }
                    saveFileToken(params).then((res4) => {
                      this.fileList3.push(res4.data)
                      this.$set(this.addform, 'dataBodyName', name)
                      this.percentage3 = 100
                      this.first3 = true
                    })
                  }

                })
              }).catch((res2) => {
                that.$message({
                  message: '因网络延时，上传失败！请重新上传',
                  type: 'error'
                });
              })
          }


        } else {
          that.$message({
            message: '文件大小超出90G',
            type: 'error'
          });
        }

      })
    },
    // 数据报告上传
    putinMirror3(file) {
      getFileToken().then((res1) => {
        var name = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_数据报告_${file.file.name}`
        // 每个文件切片大小定为5MB
        var sliceSize = 90 * 1024 * 1024;
        //文件大小限制为最大10个G，可根据需求修改
        var filesizes = 100 * 1024 * 1024 * 1024;
        let that = this;
        const blob = file.file;
        var fileSize = blob.size;// 文件大小
        // this.fileNmae.push(blob.name)
        const fileName = blob.name;// 文件名
        //计算文件切片总数
        var totalSlice = 0;
        if (fileSize >= sliceSize) {
          totalSlice = Math.ceil(fileSize / sliceSize)
        } else {
          totalSlice = 1
        }
        var list = []

        if (fileSize <= filesizes) {
          // 循环上传
          for (let i = 0; i < totalSlice; i++) {
            let start = i * sliceSize;
            let chunk = blob.slice(start, Math.min(fileSize, start + sliceSize));
            let files = new File([chunk], name)
            let partSize = files.size
            var num = null
            num = i + 1
            let samllFileName = name + "_part_" + num + ".dat"
            let filePath = res1.data.key + samllFileName + res1.data.time_yyyyMMddHHmmssS + '.dat'
            var formData = new FormData();
            formData.append("name", '');
            formData.append("acl", 'public-read');
            formData.append("AWSAccessKeyId", res1.data.accessKey);
            formData.append("policy", res1.data.policy);
            formData.append("signature", res1.data.signature);
            formData.append("policy", res1.data.policy);
            formData.append("key", filePath);
            formData.append("Content-Type", '');
            formData.append("file", files);
            this.first4 = false
            let instance = axios.create({
              baseURL: 'baseUrl',
              data: formData,
            })
            instance.post(`${res1.data.bucketEndpoint}`, formData)
              .then((res2) => {
                let etag = res2.headers.etag
                let etags = etag.replace(/"/g, '')
                let param = {
                  storageName: res1.data.storageName,
                  filePath: filePath,
                  etag: etags,
                  fileName: samllFileName,
                  fileSize: partSize,
                  dataRegion: res1.data.dataRegion
                }
                postFileToken(param).then((res3) => {
                  let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                  let endIndex = res3.data.fileName.lastIndexOf(".dat")
                  let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                  let obj = {
                    fssFileId: res3.data.fileId,
                    partFileName: res3.data.fileName,
                    partNumber: Number(partNumber),
                    partSize: res3.data.fileSize
                  }
                  list.push(obj)
                  this.percentage4 = Number(((list.length / totalSlice) * 100).toFixed(2))
                  if (list.length == totalSlice) {
                    let params = {
                      fileName: name,
                      fileSize: fileSize,
                      partFileList: list
                    }
                    saveFileToken(params).then((res4) => {
                      this.fileList4.push(res4.data)
                      this.$set(this.addform, 'dataTestnMame', name)
                      this.percentage4 = 100
                      this.first4 = true
                    })
                  }

                })
              }).catch((res2) => {
                that.$message({
                  message: '因网络延时，上传失败！请重新上传',
                  type: 'error'
                });
              })
          }


        } else {
          that.$message({
            message: '文件大小超出90G',
            type: 'error'
          });
        }

      })
    },
    // 原始扫描图件Zip上传
    putinMirror5(file) {
      getFileToken().then((res1) => {
        var name = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_原始扫描图像_${file.file.name}`
        // 每个文件切片大小定为5MB
        var sliceSize = 90 * 1024 * 1024;
        //文件大小限制为最大10个G，可根据需求修改
        var filesizes = 100 * 1024 * 1024 * 1024;
        let that = this;
        const blob = file.file;
        var fileSize = blob.size;// 文件大小
        // this.fileNmae.push(blob.name)
        const fileName = blob.name;// 文件名
        //计算文件切片总数
        var totalSlice = 0;
        if (fileSize >= sliceSize) {
          totalSlice = Math.ceil(fileSize / sliceSize)
        } else {
          totalSlice = 1
        }
        var list = []

        if (fileSize <= filesizes) {
          // 循环上传
          for (let i = 0; i < totalSlice; i++) {
            let start = i * sliceSize;
            let chunk = blob.slice(start, Math.min(fileSize, start + sliceSize));
            let files = new File([chunk], name)
            let partSize = files.size
            var num = null
            num = i + 1
            let samllFileName = name + "_part_" + num + ".dat"
            let filePath = res1.data.key + samllFileName + res1.data.time_yyyyMMddHHmmssS + '.dat'
            var formData = new FormData();
            formData.append("name", '');
            formData.append("acl", 'public-read');
            formData.append("AWSAccessKeyId", res1.data.accessKey);
            formData.append("policy", res1.data.policy);
            formData.append("signature", res1.data.signature);
            formData.append("policy", res1.data.policy);
            formData.append("key", filePath);
            formData.append("Content-Type", '');
            formData.append("file", files);
            this.first2 = false
            let instance = axios.create({
              baseURL: 'baseUrl',
              data: formData,
              timeout: 1000000,
            })
            instance.post(`${res1.data.bucketEndpoint}`, formData)
              .then((res2) => {
                let etag = res2.headers.etag
                let etags = etag.replace(/"/g, '')
                let param = {
                  storageName: res1.data.storageName,
                  filePath: filePath,
                  etag: etags,
                  fileName: samllFileName,
                  fileSize: partSize,
                  dataRegion: res1.data.dataRegion
                }
                postFileToken(param).then((res3) => {
                  let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                  let endIndex = res3.data.fileName.lastIndexOf(".dat")
                  let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                  let obj = {
                    fssFileId: res3.data.fileId,
                    partFileName: res3.data.fileName,
                    partNumber: Number(partNumber),
                    partSize: res3.data.fileSize
                  }
                  list.push(obj)
                  this.percentage5 = Number(((list.length / totalSlice) * 100).toFixed(2))
                  if (list.length == totalSlice) {
                    let params = {
                      fileName: name,
                      fileSize: fileSize,
                      partFileList: list
                    }
                    saveFileToken(params).then((res4) => {
                      this.fileList5.push(res4.data)
                      this.percentage5 = 100
                      this.first5 = true
                    })

                  }

                })
              }).catch((res2) => {
                that.$message({
                  message: '因网络延时，上传失败！请重新上传',
                  type: 'error'
                });
              })
          }


        } else {
          that.$message({
            message: '文件大小超出90G',
            type: 'error'
          });
        }

      })
    },
    // 打开参数弹框
    parameterClick(formName) {
      this.innerVisible = true
      // this.$refs[formName].resetFields()
    },
    // 岩心照片上传文件移除
    handleRemove1(file, fileList) {
    },
    // 岩心照片上传文件
    handlePreview1(response, file, fileList) {
    },
    // 测试报告上传文件移除
    handleRemove4(file, fileList) {
    },
    // 测试报告上传文件
    handlePreview4(response, file, fileList) {
    },
    // 大类选择
    bigTypechange(info) {
      this.addform.dataTypeId = ''
      this.smileOptions = []
      this.dialogType = info
      if (info == 1) {
        listPost({ dataCategory: 1 }).then((res) => {
          this.smileOptions = this.changeSelectList(res.data)
        })
        this.formType = 'parameter1Form'
      } else if (info == 2) {
        this.formType = 'parameter2Form'
        listPost({ dataCategory: 2 }).then((res) => {
          this.smileOptions = this.changeSelectList(res.data)
        })
      } else if (info == 3) {
        this.formType = 'parameter3Form'
        listPost({ dataCategory: 3 }).then((res) => {
          this.smileOptions = this.changeSelectList(res.data)
        })
      } else if (info == 4) {
        this.formType = 'parameter4Form'
        listPost({ dataCategory: 4 }).then((res) => {
          this.smileOptions = this.changeSelectList(res.data)
        })
      } else {
        this.smileOptions = []
      }

    },
    // 下拉框字段转化
    changeSelectList(value) {
      let list = []
      value.map((item) => {
        let obj = {
          value: "",
          label: "",
        }
        obj.value = item.id
        obj.label = item.name
        list.push(obj)
      })
      return list
    },
    // 小类选择
    smailTypechange(info) {
      // 如果有底深，才能上传原始扫描图件
      if (this.addform.wellName && this.addform.topDepth && this.addform.bottomDepth) {
        this.originalStatus = false
      } else {
        this.originalStatus = true
      }
      if (this.addform.wellName && this.addform.topDepth) {
        this.btnStatus = false
        this.smileOptions.map((res) => {
          if (res.value == info) {
            this.addform.name = res.label
          }
        })
      } else {
        this.btnStatus = true
        this.$message({
          message: '请先填写井名和取样深度,再次选择小类',
          type: 'error'
        });
      }

    },
    //基本信息展开-收起
    retractClick(info) {
      if (info == '展开') {
        this.retractStatue = false
      } else {
        this.retractStatue = true
      }
    },
    // 编辑
    handleClick(row) {
      this.clearForm()
      this.btnStatus = false
      this.dialogStatus = true
      this.dierlogTitle = '岩心归档(编辑)'
      this.wellDisabled = true
      this.topDepthDisabled = true
      this.dataCategoryDisabled = true
      this.dataTypeIdDisabled = true

      informationDetails(row.archiveId).then(response => {
        if (response.data.bottomDepth) {
          this.originalStatus = false
        } else {
          this.originalStatus = true
        }
        this.addform = response.data;
        let a = ''
        response.data.coreImageFileList.map((res) => {
          a = res.fileName + ' ' + a
        })
        let b = ''
        response.data.originalScanImageFileList.map((res) => {
          b = res.fileName + ' ' + b
        })
        this.addform.corePhotoNmae = a
        this.addform.mapName = b
        this.addform.dataBodyName = response.data.refactorDataBodyFile ? response.data.refactorDataBodyFile.fileName : ""
        this.addform.dataTestnMame = response.data.testReportFile ? response.data.testReportFile.fileName : ""
        this.fileList1 = response.data.coreImageFileList
        this.fileList2 = response.data.originalScanImageFileList
        this.fileList3.push(response.data.refactorDataBodyFile)
        this.fileList4.push(response.data.testReportFile)
        this.fileList5.push(response.data.testReportFile)
        if (row.dataCategory == 1) {
          this.parameter1 = response.data.testInfo.testParams
          listPost({ dataCategory: 1 }).then((res) => {
            this.smileOptions = this.changeSelectList(res.data)
            this.smileOptions.map((res) => {
              if (row.dataTypeId == res.value) {
                this.addform.name = res.label
              }
            })
          })
          this.formType = 'parameter1Form'

        } else if (row.dataCategory == 2) {
          this.parameter2 = response.data.testInfo.testParams
          this.formType = 'parameter2Form'
          listPost({ dataCategory: 2 }).then((res) => {
            this.smileOptions = this.changeSelectList(res.data)
            this.smileOptions.map((res) => {
              if (row.dataTypeId == res.value) {
                this.addform.name = res.label
              }
            })
          })
        } else if (row.dataCategory == 3) {
          this.parameter3 = response.data.testInfo.testParams
          this.formType = 'parameter3Form'
          listPost({ dataCategory: 3 }).then((res) => {
            this.smileOptions = this.changeSelectList(res.data)
            this.smileOptions.map((res) => {
              if (row.dataTypeId == res.value) {
                this.addform.name = res.label
              }
            })
          })
        } else if (row.dataCategory == 4) {
          this.parameter4 = response.data.testInfo.testParams
          this.formType = 'parameter4Form'
          listPost({ dataCategory: 4 }).then((res) => {
            this.smileOptions = this.changeSelectList(res.data)
            this.smileOptions.map((res) => {
              if (row.dataTypeId == res.value) {
                this.addform.name = res.label
              }
            })
          })
        }
        this.loading = false;
      });
      this.addDialogVisible = true

    },
    // 搜索
    searchInfo() {
      this.form.pageNo = 1;
      this.getInformation();
    },
    // 分页
    handleCurrentChange(val) {
      this.form.pageNo = val
      this.getInformation()
    },
    // 下载报告
    async downloadFile(info) {

      if (info.testReportFileInfo) {
        this.getFile(info.testReportFileInfo.fileId, 'other')
      }

    },
    // 删除弹框
    deletClick(info) {
      this.deletInfo = info
      this.dialogVisible = true
    },
    // 删除事件
    handleClose(info) {
      if (info == '确定') {
        delArchivedInformation(this.deletInfo.archiveId).then(response => {
          this.dialogVisible = false
          this.form = {
            wellName: "",
            dataTypeId: '',
            coreName: '',
            block: '',
            layerName: '',
            pageNo: 1,
            pageSize: 10,
          },
            this.getInformation()
        });
      } else {
        this.dialogVisible = false
      }

    },
    // 归档点击
    fileClick(formName) {
      this.dataCategoryDisabled = true
      this.dataTypeIdDisabled = true
      this.btnStatus = true
      this.dialogStatus = true
      this.dierlogTitle = '岩心归档(新增)'
      this.addDialogVisible = true
      this.wellDisabled = false
      this.topDepthDisabled = false
      this.dataTypeIdDisabled = false
      if (this.$refs.ruleForm !== undefined) this.$refs.ruleForm.resetFields()
      this.clearForm()
      this.fileList1 = []
      this.fileList2 = []
      this.fileList3 = []
      this.fileList4 = []
      if (this.$refs.parameter1Form !== undefined) this.$refs.parameter1Form.resetFields()
      if (this.$refs.parameter2Form !== undefined) this.$refs.parameter2Form.resetFields()
      if (this.$refs.parameter3Form !== undefined) this.$refs.parameter3Form.resetFields()
      if (this.$refs.parameter4Form !== undefined) this.$refs.parameter4Form.resetFields()
    },
    // 清空form
    clearForm() {
      this.addform = {
        id: '',
        wellName: '',
        topDepth: '',
        bottomDepth: '',
        block: '',
        layedataTyperName: '',
        coreRadius: '',
        coreLength: '',
        dataCategory: '',
        dataTypeId: '',
        coreImageFileList: [],
        originalScanImageFileList: [],
        refactorDataBodyFile: null,
        testReportFile: null,
        testInfo: {
          companyName: "",
          deviceName: "",
          scanVoltage: "",
          sampleSize: '',
          resolution: "",
          testParams: {
            fileId: '',
            fileName: '',
            location: "",

          },
          testParams: {}
        }
      };
      this.parameter1 = {}
      this.parameter2 = {}
      this.parameter3 = {}
      this.parameter4 = {}
    },
    // 超出限制个数提示
    handleExceed(files, fileList) {
      console.log('当前限制一次性最多上传1000个文件', files, fileList)
      this.$message.warning("当前限制一次性最多上传1000个文件")
    },
    changeFile(file, fileList) {
      this.first2 = false
      this.originalStatus = true
      this.fileSize = file.size
      this.disabledUpload = true
      // 符合条件的进入待传列表
      this.upFileList = []
      for (let x of fileList) {
        this.upFileList.push(x)
        this.percentTotal = this.upFileList.length
        this.percentNow = 0
        this.showPercent = false
        this.showDesc = ''
      }
      clearTimeout(this.time)
      this.time = setTimeout(() => {
        this.time = null
        console.log('防抖 高频触发后n秒内只会执行一次  再次触发重新计时')
        this.fnBegin()//说明此时change了所有文件了 可以上传了
      }, 1500)



    },
    fnBegin() {
      console.log('此时change了所有文件 开始上传', this.upFileList)
      this.totalSlice = this.upFileList.length
      this.submitUpload2()
    },

    // 正式上传掉后端接口
    submitUpload2() {
      getFileToken().then((res1) => {
        var firstForm = res1.data
        var name = `${this.addform.wellName}_${this.addform.name}_${this.addform.topDepth}_原始扫描图像_${this.upFileList[0] ? this.upFileList[0].name : ""}`
        var samllFileName = name + "_part_" + 1 + ".dat"
        this.filePath = firstForm.key + samllFileName + firstForm.time_yyyyMMddHHmmssS + '.dat'
        if (this.upFileList.length > 0) {
          let list = []
          this.showPercent = true
          this.fileNum = new FormData()  // new formData对象
          this.fileNum.append("name", '');
          this.fileNum.append("acl", 'public-read');
          this.fileNum.append("AWSAccessKeyId", firstForm.accessKey);
          this.fileNum.append("policy", firstForm.policy);
          this.fileNum.append("signature", firstForm.signature);
          this.fileNum.append("policy", firstForm.policy);
          this.fileNum.append("key", this.filePath);
          this.fileNum.append("Content-Type", '');
          this.fileNum.append("file", this.upFileList[0].raw);
          let instance = axios.create({
            baseURL: 'baseUrl',
            data: this.fileNum,
            timeout: 1000000,
          })
          instance.post(`${firstForm.bucketEndpoint}`, this.fileNum)
            .then((res2) => {
              this.etag = res2.headers.etag
              let etags = res2.headers.etag.replace(/"/g, '')
              let param = {
                storageName: firstForm.storageName,
                filePath: this.filePath,
                etag: etags,
                fileName: samllFileName,
                fileSize: this.upFileList[0].raw.size,
                dataRegion: firstForm.dataRegion
              }
              postFileToken(param).then((res3) => {
                let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                let endIndex = res3.data.fileName.lastIndexOf(".dat")
                let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                let obj = {
                  fssFileId: res3.data.fileId,
                  partFileName: res3.data.fileName,
                  partNumber: Number(partNumber),
                  partSize: res3.data.fileSize
                }
                list.push(obj)
                let params = {
                  fileName: name,
                  fileSize: this.upFileList[0].raw.size,
                  partFileList: list
                }
                saveFileToken(params).then((res4) => {
                  this.fileList2.push(res4.data)
                  this.percentNow = this.percentNow + 1
                  this.percentage2 = Number(((this.percentNow / this.totalSlice) * 100).toFixed(2))
                  this.upFileList.shift()
                  setTimeout(() => {
                    this.submitUpload2()
                  }, 1000)
                }).catch(error => {
                  console.log(error)
                  _vm.$message({
                    message: error || '上传失败',
                    type: "error",
                  })

                  // 每次上传当前一个后 不论成功失败就删除当前这个--如果上传失败想继续传当前这个 就把这两行注释掉
                  this.upFileList.shift()

                  // 进行递归 上传下一个
                  this.showDesc = '上传结束，部分文件上传失败'
                  this.submitUpload2()
                })
              }).catch((res) => {
                // _vm.$message({
                //   message: res.data || '上传失败',
                //   type: "error",
                // })

                // start
                setTimeout(() => {
                  postFileToken(param).then((res3) => {
                    let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                    let endIndex = res3.data.fileName.lastIndexOf(".dat")
                    let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                    let obj = {
                      fssFileId: res3.data.fileId,
                      partFileName: res3.data.fileName,
                      partNumber: Number(partNumber),
                      partSize: res3.data.fileSize
                    }
                    list.push(obj)
                    let params = {
                      fileName: name,
                      fileSize: this.upFileList[0].raw.size,
                      partFileList: list
                    }
                    saveFileToken(params).then((res4) => {
                      this.fileList2.push(res4.data)
                      this.percentNow = this.percentNow + 1
                      this.percentage2 = Number(((this.percentNow / this.totalSlice) * 100).toFixed(2))
                      this.upFileList.shift()
                      setTimeout(() => {
                        this.submitUpload2()
                      }, 1000)
                    }).catch(error => {
                      console.log(error)
                      _vm.$message({
                        message: error || '上传失败',
                        type: "error",
                      })

                      // 每次上传当前一个后 不论成功失败就删除当前这个--如果上传失败想继续传当前这个 就把这两行注释掉
                      this.upFileList.shift()

                      // 进行递归 上传下一个
                      this.showDesc = '上传结束，部分文件上传失败'
                      this.submitUpload2()
                    })
                  }).catch((res) => {
                    _vm.$message({
                      message: res.data || '上传失败',
                      type: "error",
                    })
                  })
                }, 1000)

              })
            }).catch((res2) => {
              console.log(res2, 444444444444)
              let etags = this.etag.replace(/"/g, '')
              let param = {
                storageName: firstForm.storageName,
                filePath: this.filePath,
                etag: etags,
                fileName: this.samllFileName,
                fileSize: this.fileSize,
                dataRegion: firstForm.dataRegion
              }
              postFileToken(param)
                .then((res3) => {
                  let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                  let endIndex = res3.data.fileName.lastIndexOf(".dat")
                  let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                  let obj = {
                    fssFileId: res3.data.fileId,
                    partFileName: res3.data.fileName,
                    partNumber: Number(partNumber),
                    partSize: res3.data.fileSize
                  }
                  list.push(obj)
                  let params = {
                    fileName: this.name,
                    fileSize: this.fileSize,
                    partFileList: list
                  }
                  saveFileToken(params).then((res4) => {

                    this.fileList2.push(res4.data)
                    this.percentNow = this.percentNow + 1
                    this.upFileList.shift()
                    this.submitUpload2()
                  }).catch(error => {
                    console.log(error)
                    _vm.$message({
                      message: error || '上传失败',
                      type: "error",
                    })

                    // 每次上传当前一个后 不论成功失败就删除当前这个--如果上传失败想继续传当前这个 就把这两行注释掉
                    this.percentNow = this.percentNow + 1
                    this.upFileList.shift()

                    // 进行递归 上传下一个
                    this.showDesc = '上传结束，部分文件上传失败'
                    this.submitUpload2()
                  })



                }).catch(res3 => {
                  console.log(res3, "重新发起保存索引请求")
                  // 如果异常重新发起索引的保存
                  postFileToken(param).then((res3) => {
                    let startIndex = res3.data.fileName.lastIndexOf("_part_") + 6
                    let endIndex = res3.data.fileName.lastIndexOf(".dat")
                    let partNumber = res3.data.fileName.slice(startIndex, endIndex)
                    let obj = {
                      fssFileId: res3.data.fileId,
                      partFileName: res3.data.fileName,
                      partNumber: Number(partNumber),
                      partSize: res3.data.fileSize
                    }
                    list.push(obj)
                    let params = {
                      fileName: this.name,
                      fileSize: this.fileSize,
                      partFileList: list
                    }
                    saveFileToken(params).then((res4) => {

                      this.fileList2.push(res4.data)
                      this.percentNow = this.percentNow + 1
                      this.upFileList.shift()
                      this.submitUpload2()
                    }).catch(error => {
                      console.log(error)
                      _vm.$message({
                        message: error || '上传失败',
                        type: "error",
                      })

                      // 每次上传当前一个后 不论成功失败就删除当前这个--如果上传失败想继续传当前这个 就把这两行注释掉
                      this.percentNow = this.percentNow + 1
                      this.upFileList.shift()

                      // 进行递归 上传下一个
                      this.showDesc = '上传结束，部分文件上传失败'
                      this.submitUpload2()
                    })
                  })
                })
            })
        } else {
          this.disabledUpload = false
          this.showPercent = false
          this.upFileList = [] //清空待传列表

          this.$refs.upload1.clearFiles()

          if ((this.percentNow == this.percentTotal) && this.percentTotal) {
            this.$message.success(this.showDesc ? this.showDesc : '已全部上传成功！')
            this.first2 = true
            let name = ''
            this.fileList2.map((res) => {
              name = res.fileName + ',' + name
            })
            this.$set(this.addform, 'mapName', name)
            this.percentTotal = 0
            this.percentNow = 0
            this.showDesc = ''

          } else if ((this.percentNow == this.percentTotal) && this.percentTotal == 0) {
            this.$message.warning('请先选择文件！')
            this.percentTotal = 0
            this.percentNow = 0
          } else {
            this.$message.success('已部分上传成功，且取消后续文件上传！')
            this.percentTotal = 0
            this.percentNow = 0

          }

          return false
        }
      })


    },
    // 文件压缩
    fileYasuo() {
      const zip = JSZip()
      const folder = zip.folder("imgs") //创建一个imgs的文件夹
      folder.file("img.txt", x.raw) //朝imgs文件夹里面添加一个文件
      zip.generateAsync({ type: "blob" }).then((res) => {
        console.log(res, 2232423423423534554)
      })
    },
    // 终止后需上传
    submitAbort() {
      this.showPercent = false
      // .abort()不生效，故自己直接将this.upFileList置空 那么就不会走到递归了 就制止后续的上传了
      this.upFileList = []


      // this.upFileList.forEach(ele => {
      //   this.$refs.upload1.abort(ele)
      // })
      // this.$refs.upload1.abort()
      // this.$message.warning('已取消后续文件上传！')
    },
    fileErr(err, file, fileList) {
      this.$message({
        message: file.name + '上传失败',
        type: "error",
      })
    },



    // 这两个事件不会再触发--因为阻止了自动上传
    beforeAvatarUpload(file) {
      console.log('上传文件前', file)
    },
    msgSuccessOne(data, file, fileList) {
      console.log('成功', file)
    },
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .info_box {
    width: 100%;
    display: flex;
    align-items: center;

    .more_img {
      display: block;
      width: 10px;
      height: 10px;
      margin-left: 5px;
      cursor: pointer;
    }
  }

  .info_box1 {
    width: 100%;
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    margin-left: 20px;
    position: relative;
  }

  .searchSty {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    margin-bottom: 20px;

    .btnSty {
      width: 100px;
    }

    .formSty {
      display: flex;
      align-items: center;
      margin-left: 20px;

      .el-form-item {
        margin-bottom: 0px;
      }
    }
  }

  .repoartSty {
    color: blue;
    cursor: pointer;
  }


}
</style>
